﻿using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

using Think.Lenovo.Com.Models;
namespace Think.Lenovo.Com.DataAccess
{
    public class CompanyType
    {
        public LinkedList<CompanyTypeModel> GetCompanyTypeModels()
        {
            String conn = ConfigurationManager.ConnectionStrings["MySqlHost"].ConnectionString;
            StringBuilder sql = new StringBuilder(56);
            sql.Append("Select * From tbl_companytype order by Seq");
            DataSet ds = MysqlHelper.Query(conn, sql.ToString());
            LinkedList<CompanyTypeModel> list = new LinkedList<CompanyTypeModel>();
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    CompanyTypeModel model = new CompanyTypeModel();
                    model.Id = Convert.ToInt32(row["Id"]);
                    model.CompanyTypeName = Convert.ToString(row["typeName"]);
                    model.Seq = Convert.ToInt32(row["Seq"]);
                    list.AddLast(model);
                }
            }
            return list;
        }
    }
}
